﻿using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using Event.Services;
using Event.Models;

namespace Event.ViewModels;

[ObservableObject]
public partial class FunctionPageViewModel {
    public ObservableCollection<Poetry> Poetries { get; }

    public FunctionPageViewModel(IPoetryService poetryService) {
        var poetries = poetryService.GetPoetries();
        Poetries = new ObservableCollection<Poetry>();
        foreach (var poetry in poetries) {
            Poetries.Add(poetry);
        }

        poetryService.PoetryAdded +=
            (sender, args) => Poetries.Add(args.Poetry);
    }
}